#ifndef CAR_POWER_RANGE_STRUCT_HH
#define CAR_POWER_RANGE_STRUCT_HH 1


#include <string>
#include <iostream>
#include <vector>
#include "otl8.hpp"

static const char*  car_power_range_struct_s = "SELECT ID, MIN_POWER, MAX_POWER, NOTES FROM CAR_POWER_RANGE_STRUCT";

static const char*  car_power_range_struct_i = "INSERT INTO CAR_POWER_RANGE_STRUCT ( ID, MIN_POWER, MAX_POWER, NOTES )VALUES(:f1<int>, :f2<int>, :f3<int>, :f4<char[128]>)";

static const char* car_power_range_struct_c = "CREATE TABLE CAR_POWER_RANGE_STRUCT ( ID INTEGER , MIN_POWER INTEGER , MAX_POWER INTEGER , NOTES VARCHAR(128) )";
class car_power_range_struct
{



public:
car_power_range_struct():_id(0), _min_power(0), _max_power(0), _notes(""){_select=car_power_range_struct_s;_insert=car_power_range_struct_i;_create=car_power_range_struct_c;}


car_power_range_struct(int a__id, int a__min_power, int a__max_power, std::string a__notes):_id(a__id) , _min_power(a__min_power) , _max_power(a__max_power) , _notes(a__notes) {_select=car_power_range_struct_s;_insert=car_power_range_struct_i;_create=car_power_range_struct_c;}


int id(){return  _id;}
void set_id(int a__id){ _id = a__id;}


int min_power(){return  _min_power;}
void set_min_power(int a__min_power){ _min_power = a__min_power;}


int max_power(){return  _max_power;}
void set_max_power(int a__max_power){ _max_power = a__max_power;}


std::string notes(){return  _notes;}
void set_notes(std::string a__notes){ _notes = a__notes;}


car_power_range_struct & operator=( const car_power_range_struct & x)
{
	_id =  x._id;
	_min_power =  x._min_power;
	_max_power =  x._max_power;
	_notes =  x._notes;
	return *this;
}


bool operator==( const car_power_range_struct & x)
{
	return 	_id ==  x._id &&
	_min_power ==  x._min_power &&
	_max_power ==  x._max_power &&
	_notes ==  x._notes;
}


friend std::istream& operator >> (std::istream& ist, car_power_range_struct & t)
{
	if (!(ist >> t._id)) return ist;
	if (!(ist >> t._min_power)) return ist;
	if (!(ist >> t._max_power)) return ist;
	if (!(ist >> t._notes)) return ist;

	return ist;
}

friend std::ostream& operator << (std::ostream& ost, car_power_range_struct & t)
{
	ost << t._id << " ";
	ost << t._min_power << " ";
	ost << t._max_power << " ";
	ost << t._notes << " ";

	return ost;
}

/*
friend otl_stream& operator >> (otl_stream& ist, car_power_range_struct & t)
{
	ist >> t._id;
	ist >> t._min_power;
	ist >> t._max_power;
	ist >> t.buf; t._notes=(const char*)t.buf;

	return ist;
}

friend otl_stream& operator << (otl_stream& ost, car_power_range_struct & t)
{
	ost << t._id ;
	ost << t._min_power ;
	ost << t._max_power ;
	ost << t._notes.c_str() ;

	return ost;
}
*/

std::string select_stmt() { return _select; }
std::string insert_stmt() { return _insert; }
std::string create_stmt() { return _create; }


private:

	int	_id;
	int	_min_power;
	int	_max_power;
	std::string	_notes;
	std::string _create;
	std::string _select;
	std::string _insert;
char buf[128];
};
#endif
